<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
    :d-table-config="dTableConfig"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/diagnosis/inspct/inspectstds',
      // Web路径
      webPath: 'health/diagnosis/Inspct/InspectStds',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "name",
              name: "名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "inspectCode",
              name: "检查项目编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "inspectName",
              name: "检查项目名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "inspectTypeCode",
              name: "检查结果类型编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "inspectTypeName",
              name: "检查结果类型名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "code",
          name: "编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "name",
          name: "名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "inspectCode",
          name: "检查项目编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "inspectName",
          name: "检查项目名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "inspectTypeCode",
          name: "检查结果类型编码",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "inspectTypeName",
          name: "检查结果类型名称",
          type: "text",
          span: 6,
          config: {
            edit: false
          }
        },
        {
          code: "stdsWeight",
          name: "标准权重",
          type: "number",
          span: 6,
          config: {
            edit: false,
            precision: 2
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "code",
              name: "编码",
              span: 6,
              type: "text",
              config: {
                edit: false,
                require: true,
                rules: [
                  { required: true, message: '请输入编码', trigger: 'blur' }
                ]
              }
            },
            {
              code: "name",
              name: "名称",
              span: 6,
              type: "text",
              config: {
                edit: false,
                require: true,
                rules: [
                  { required: true, message: '请输入名称', trigger: 'blur' }
                ]
              }
            },
            {
              code: "inspectCode",
              span: 6,
              name: "检查项目编码",
              type: "popup",
              config: {
                url: "health/diagnosis/inspct/inspct",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择检查项目', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData("inspectName", row.name)
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("inspectId", row.id)
                }
              }
            },
            {
              code: "inspectName",
              name: "检查项目名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "inspectTypeCode",
              span: 6,
              name: "检查结果类型编码",
              type: "popup",
              config: {
                url: "health/diagnosis/inspct/inspecttype",
                filedList: [
                  { code: 'id', name: 'ID' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true,
                rules: [
                  { required: true, message: '请选择结果类型', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData("inspectTypeName", row.name)
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("inspectTypeId", row.id)
                }
              }
            },
            {
              code: "inspectTypeName",
              name: "检查结果类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "stdsWeight",
              name: "标准权重",
              type: "number",
              span: 6,
              config: {
                edit: false,
                precision: 2
              }
            }
          ]
        }
      ],
      // 子表配置
      dTableConfig: [
        {
          key: "inspectStdsItem",
          name: "采购订单项",
          url: "health/diagnosis/inspct/inspectstdsitem'",
          columns: [
            // {
            //   code: "inspectStdsCode",
            //   span: 6,
            //   name: "评判标准编码",
            //   type: "popup",
            //   config: {
            //     url: "health/diagnosis/inspct/inspectrecord",
            //     filedList: [
            //       { code: 'id', name: 'ID', config: { align: "center" }},
            //       { code: 'code', name: '编码', config: { align: "center" }},
            //       { code: 'name', name: '名称', config: { align: "center" }}
            //     ],
            //     searcher: {},
            //     defaultValue: "",
            //     minLength: 0,
            //     maxLength: 20,
            //     disabled: false,
            //     require: true,
            //     rules: [
            //       { required: true, message: '请选择评判标准', trigger: 'blur' }
            //     ]
            //   },
            //   handleEvent: {
            //     /**
            //      * 开窗组件被选择
            //      * @param line
            //      * @param code
            //      * @param row
            //      */
            //     onPopupClick: (line, code, row) => {
            //       this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", "inspectStdsName", row.name)
            //       this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", code, row.code)
            //       this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", "inspectStdsId", row.id)
            //     }
            //   }
            // },
            // {
            //   code: "inspectStdsName",
            //   name: "评判标准名称",
            //   type: "text",
            //   span: 6,
            //   config: {
            //     edit: false,
            //     disabled: true
            //   }
            // },
            {
              code: "inspectParamCode",
              span: 6,
              name: "检查参数编码",
              type: "popup",
              config: {
                url: "health/diagnosis/inspct/inspectparam",
                filedList: [
                  { code: 'id', name: 'ID', config: { align: "center" }},
                  { code: 'code', name: '编码', config: { align: "center" }},
                  { code: 'name', name: '名称', config: { align: "center" }}
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                require: true,
                rules: [
                  { required: true, message: '请选择检查参数', trigger: 'blur' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param line
                 * @param code
                 * @param row
                 */
                onPopupClick: (line, code, row) => {
                  this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", "inspectParamName", row.name)
                  this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", code, row.code)
                  this.$refs.commonPage.updateDTableData(line, "inspectStdsItem", "inspectParamId", row.id)
                }
              }
            },
            {
              code: "inspectParamName",
              name: "检查参数名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                disabled: true
              }
            },
            {
              code: "upperLimit",
              name: "上限",
              type: "number",
              span: 6,
              config: {
                edit: false,
                disabled: true,
                precision: 2
              }
            },
            {
              code: "lowerLimit",
              name: "下限",
              type: "number",
              span: 6,
              config: {
                edit: false,
                disabled: true,
                precision: 2
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
